/************************************************************************
 PROJECT     : Phoenix iTill System Database Creation Scripts
 FILE        : ClearTables.sql
 REVISION    : 1.0
 FUNCTION    : Clear database
 AUTHOR      : Helen Volosuk <lilo@axmor.com> 

 COMMENTS    : WARNING! The correct order of script application is:
               ClearDatabase.sql
               CreateTables.sql
               CreateProcs.sql [*]

**************************************************************************
 CHANGE HISTORY:
 Revision      Date       Author
 -------------------------------------------------------------------------
 Revision 1.0  2005/09/02 lilo 
 Initial draft

**************************************************************************/

SET XACT_ABORT ON
SET NOCOUNT ON
BEGIN TRANSACTION

--drop procs



--drop tables

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'BillNoSale') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE BillNoSale
GO


IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'EmployeeSchedule') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE EmployeeSchedule
GO

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'AppointmentSchedule') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE AppointmentSchedule
GO

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'SalonSchedule') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE SalonSchedule
GO

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'Schedule') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE Schedule
GO

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'Payment') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE Payment
GO

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'BillProduct') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE BillProduct
GO

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'Appointment') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE Appointment
GO

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'Bill') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE Bill
GO

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'Employee') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE Employee
GO

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'SUser') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE SUser
GO


IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'Client') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE Client
GO


IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'Product') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE Product
GO

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'ServiceParam') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE ServiceParam
GO

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'MasterLevel') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE MasterLevel
GO

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'Service') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE Service
GO

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'PrivilegeGroup') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE PrivilegeGroup
GO

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'SGroup') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE SGroup
GO

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'Privilege') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE Privilege
GO

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'SImage') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE SImage
GO

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'Salon') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE Salon
GO

COMMIT TRANSACTION

